package org.bw.bookstore.book.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.bw.bookstore.book.service.impl.ReplenishmentServiceImpl;
import org.bw.bookstore.common.entity.TbReplenishmentRecord;
import org.bw.bookstore.common.entity.TbReplenishmentRules;
import org.bw.bookstore.common.entity.TbReplenishmentTask;
import org.bw.bookstore.common.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
*@program: wisdom_bookstore
*@description: 补货控制类
*@author: 孙冬雪
*@create: 2020-11-01 09:58
*/
@RestController
@Slf4j
@CrossOrigin
@Api(tags = "接口-补货管理微服务")
public class ReplenishmentController {

    @Autowired
    private ReplenishmentServiceImpl replenishmentService;

    @ApiOperation(value = "制定补货规则", notes = "制定补货规则")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "startTime", value = "补货开始时间", dataType = "Date", required = true),
            @ApiImplicitParam(name = "endTime", value = "补货结束时间", dataType = "Date", required = true),
            @ApiImplicitParam(name = "timeInterval", value = "时间间隔", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "timeUnit", value = "时间单位", dataType = "String", required = true),
            @ApiImplicitParam(name = "staffMemberCode", value = "店长标识", dataType = "String", required = true)
    })
    @PostMapping("/makeReplenishmentRules")
    public ResponseResult makeReplenishmentRules(@ApiIgnore TbReplenishmentRules replenishmentRules){
        return replenishmentService.makeReplenishmentRules(replenishmentRules);
    }

    @ApiOperation(value = "发布补货任务", notes = "发布补货任务")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "bookDetailedCode", value = "图书详情标识", dataType = "String", required = true),
            @ApiImplicitParam(name = "planReplenishmentNum", value = "计划补货量", dataType = "Integer", required = true)
    })
    @PostMapping("/editReplenishmentTask")
    public ResponseResult editReplenishmentTask(@ApiIgnore TbReplenishmentTask replenishmentTask){
        return replenishmentService.editReplenishmentTask(replenishmentTask);
    }

    @ApiOperation(value = "录入单品信息", notes = "录入单品信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "rfid", value = "图书单品rfid", dataType = "String", required = true),
            @ApiImplicitParam(name = "qrCode", value = "图书单品条形码", dataType = "String", required = true),
            @ApiImplicitParam(name = "bookDetailedCode", value = "图书标识", dataType = "String", required = true),
            @ApiImplicitParam(name = "id", value = "工作人员id", dataType = "Integer", required = true)
    })
    @PostMapping("/entryBookSingle")
    public ResponseResult entryBookSingle(String bookDetailedCode,String rfid,String qrCode,Integer id){
        return replenishmentService.entryBookSingle(bookDetailedCode,rfid,qrCode,id);
    }

    @ApiOperation(value = "生成补货记录", notes = "生成补货记录")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "replenishmentTaskCode", value = "补货任务标识", dataType = "String", required = true),
            @ApiImplicitParam(name = "staffMemberCode", value = "工作人员标识", dataType = "String", required = true)
    })
    @PostMapping("/generateReplenishmentRecord")
    public ResponseResult generateReplenishmentRecord(@ApiIgnore TbReplenishmentRecord replenishmentRecord){
        return replenishmentService.generateReplenishmentRecord(replenishmentRecord);
    }

    @ApiOperation(value = "查询补货记录", notes = "查询补货记录")
    @PostMapping("/getReplenishmentRecord")
    public ResponseResult getReplenishmentRecord(){
        return replenishmentService.getReplenishmentRecord();
    }

    /**
     * TODO 查询全部未完成的补货任务
     * @Description:
     * @Author: liuwu
     * @Date: 2020/10/26 18:54
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value="查询全部未完成的补货任务", notes="查询全部未完成的补货任务")
    @PostMapping("/getReplenishmentTaskByNoFinish")
    public ResponseResult getReplenishmentTaskByNoFinish(){
        return replenishmentService.getReplenishmentTaskByNoFinish();
    }

    /**
     * TODO 查询全部已完成的补货任务
     * @Description:
     * @Author: liuwu
     * @Date: 2020/10/26 18:54
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value="查询全部已完成的补货任务", notes="查询全部已完成的补货任务")
    @PostMapping("/getReplenishmentTaskByFinish")
    public ResponseResult getReplenishmentTaskByFinish(){
        return replenishmentService.getReplenishmentTaskByFinish();
    }

    /**
     * TODO 查询全部补货任务
     * @Description:
     * @Author: liuwu
     * @Date: 2020/10/26 18:54
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value="查询全部补货任务", notes="查询全部补货任务")
    @PostMapping("/getReplenishmentTask")
    public ResponseResult getReplenishmentTask(){
        return replenishmentService.getReplenishmentTask();
    }
/*

    @ApiOperation(value = "工作人员登录", notes = "工作人员登录")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "userName", value = "工作人员账号", dataType = "String", required = true),
            @ApiImplicitParam(name = "userPass", value = "工作人员密码", dataType = "String", required = true)
    })
    @PostMapping("/loginStaffMember")
    public ResponseResult loginStaffMember(String userName,String userPass){
        return replenishmentService.loginStaffMember(userName,userPass);
    }

    @ApiOperation(value="查询全部图示品类", notes="查询全部图示品类")
    @PostMapping("/getBookDetailed")
    public ResponseResult getBookDetailed(){
        return replenishmentService.getBookDetailed();
    }
*/



}
